
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>


#include <svlis/svlis.h>
#include <svlis/sv_cols.h>

#include <iostream>

using namespace std;


int
main(int argc, char ** argv)
{



   svlis_init();

// Define the block's corners.

  sv_point corner_a = sv_point(0,0,0);
  sv_point corner_b = sv_point(1,1,1);

  //sv_point corners[100];
  
  //  for(int i=0; i<100; i++)
  //corners[i]=sv_point(-1.0+0.02*i,1,1);
// Make the cube; it will be a set

  sv_set block = cuboid(corner_a, corner_b);

// Colour it green - note British spellinsv_point corner_a = sv_point(0,0,0);g...
// Note also that member functions have no side effects,
// so we assign the coloured block to the sv_set block.

  block = block.colour(SV_GREEN);

// Define a sphere centred on one corner, radius 0.8

/*  for(int i=0; i<100; i++)
    {
      
  sv_set sph = sphere(corners[i], 0.8).colour(SV_RED);

// Subtract the sphere from the cube.

  block = block - sph;
  } */


  corner_a = sv_point(-1, -1, -1);
  corner_b = sv_point(2, 2, 2);
  sv_box interesting = sv_box(corner_a, corner_b);

// Make a svLis model by combining the shape
// and the region of interest.

  sv_model m = sv_model(block, interesting);

  // m = m.facet();
 
  // sv_set_list sets=m.set_list();
  // plot_m_p_gons(m);
  sv_primitive rr;
  
  for(double i=-1.1; i<2; i+=0.1)
    {
      cout<<i<<"\t"<<m.member(sv_point(0.5,0.5,i),&rr)<<endl;
    }
	

  
  /* while(sets.exists())
    {
      cout<<"set\n";
      
      sv_attribute a=sets.set().attribute();
      while(a.exists())
	{
	   sv_p_gon* pg;
	  cout<<" attr "<<a.tag_val()<<" "<<-pg->tag()<<endl;
	 
	    
	  if(a.tag_val() == -pg->tag())
	    {
	      cout<<"  poly!\n";
	      sv_user_attribute u = a.user_attribute();
	      pg = (sv_p_gon*)u.pointer;
	  
	      if(pg->kind==P_GON)
		{
		  sv_p_gon* begin=pg;
		  int vc=1;
		  do
		    {
		      sv_point p=pg->p;
		      cout<<vc<<"\t"<<p.x<<"\t"<<p.y<<"\t"<<p.z<<endl;
		      pg=pg->next;
		  
		    }
		  while(pg!=begin);
	      
		  cout<<"---------"<<endl;
	      
		}
	    }
	  a = a.next();
	}
      sets=sets.next();
      
    }
  */
  
  
  /*  
  // Initializes SoQt library (and implicitly also the Coin and Qt
  // libraries). Returns a top-level / shell Qt window to use.
  QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
  
  // Make a dead simple scene graph by using the Coin library, only
  // containing a single yellow cone under the scenegraph root.
  SoSeparator * root = new SoSeparator; 
  root->ref();

  SoBaseColor * col = new SoBaseColor;
  col->rgb = SbColor(1, 1, 0);
  root->addChild(col);

  root->addChild(new SoCone);
  
  // Use one of the convenient SoQt viewer classes.
  SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
  eviewer->setSceneGraph(root);
  eviewer->show();
  
  // Pop up the main window.
  SoQt::show(mainwin);
  // Loop until exit.
  SoQt::mainLoop();

  // Clean up resources.
  delete eviewer;
  root->unref(); */

  return 0;
}
